<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5">

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <title>Consent required</title>
  <link type="text/css" rel="stylesheet" href="/inner/auth/css/bootstrap.min.css">
  <script>function cancelConsent() {
    document.consent_form.reset();
    document.consent_form.submit();
  }</script>
</head>

<body>
<div class="container">
  <div class="py-5">
    <h1 class="text-center">Consent required</h1>
  </div>
  <div class="row">
    <div class="col text-center">
      <p>
        <span class="font-weight-bold text-primary" th:text="${clientId}"></span>  wants to access your account
        <span class="font-weight-bold"  sec:authentication="name">admin</span>
      </p>
    </div>
  </div>
  <div class="row pb-3">
    <div class="col text-center">
      <p>The following permissions are requested by the above app.
        <br/>Please review these and consent if you approve.</p>
    </div>
  </div>
  <div class="row">
    <div class="col text-center">
      <form name="consent_form" method="post" action="/inner/auth/oauth2/authorize">
        <input type="hidden" name="client_id" th:value="${clientId}">
        <input type="hidden" name="state" th:value="${state}">
        <input type="hidden" name="access_token" th:value="${access_token}">
          <div class="form-group form-check py-1" th:each="item:${scopesToAuthorize}">
          <input class="form-check-input" type="checkbox" name="scope" th:value="${item}" th:id="${item}">
          <label class="form-check-label" th:for="${item}" th:text="${item}"></label>
          </div>
       <p>You have already granted the following permissions to the above app:</p>
       <div class="form-group form-check py-1" th:each="item:${scopesPreviouslyAuthorized}">
            <input class="form-check-input" type="checkbox" name="scope"th:value="${item}" th:id="${item}" checked disabled>
       <label class="form-check-label"  th:for="${item}" th:text="${item}">scope</label>
        </div>
        <div class="form-group pt-3">
          <button class="btn btn-primary btn-lg" type="submit" id="submit-consent">Submit Consent</button>
        </div>
        <div class="form-group">
          <button class="btn btn-link regular" type="button" onclick="cancelConsent();" id="cancel-consent">Cancel</button>
        </div>
      </form>
    </div>
  </div>
  <div class="row pt-4">
    <div class="col text-center">
      <p>
        <small>Your consent to provide access is required.
          <br/>If you do not approve, click Cancel, in which case no information will be shared with the app.</small>
      </p>
    </div>
  </div>
</div>
</body>

</html>